<template>
  <div id="searchlist"> 


          <el-table :data="datalist" style="width: 100%" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">

               
                <el-table-column label="帐号"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.telphone }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="姓名"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.nickname }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="权限"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.manor }}
                        </span>
                    </template>
                </el-table-column>
                 <el-table-column label="团队"  align='center' width="220">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.team_name }} - {{ scope.row.team_telphone }}</span>
                    </template>
                </el-table-column>
                   <el-table-column label="产出收益"  align='center' >                   
                    <template slot-scope="scope">    
                        {{ scope.row.total_profit }}                  
                    </template>
                </el-table-column>
                <el-table-column label="金蛋"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.jindan }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="彩蛋"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.caidan }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="持有价值"  align='center' >                   
                    <template slot-scope="scope">    
                        {{ scope.row.hold_price }}     
                    </template>
                </el-table-column>
                 <el-table-column label="产出价值"  align='center' width="100px">                   
                    <template slot-scope="scope">    
                        {{scope.row.hold_wait_price   }}            
                    </template>
                </el-table-column>
                <el-table-column label="消耗蜜贝"  align='center' width="100px">                   
                    <template slot-scope="scope">    
                      {{scope.row.usekmb   }}             
                    </template>
                </el-table-column>
                <el-table-column label="收益差额"  align='center' width="100px">                   
                    <template slot-scope="scope">    
                        <span>{{ js_fun_num(scope.row.jindan,scope.row.caidan,scope.row.total_profit,scope.row.hold_price,scope.row.hold_wait_price,) }}</span>   
                    </template>
                </el-table-column>
                 
                 <el-table-column :label="variable_name4"  align='center' width="300px">                   
                    <template slot-scope="scope">                   
                         <!-- <span >当前持有:</span><span>{{ scope.row.hold_count }}</span> 
                        <span >待收货:</span><span>{{ scope.row.hold_wait_count }}</span>
                        <span >已收货:</span> <span>{{ scope.row.hold_produced_count }}</span> -->
                         <span >当前持有:</span><span>{{ scope.row.hold_count }}</span><span  class="see_span"  @click="gohold_but(scope.row,1,'当前持有')"><i class="el-icon-view el-icon--right"></i></span> 
                        <span >待产出:</span><span>{{ scope.row.hold_wait_count }}</span><span  class="see_span" @click="goharvested_but(scope.row,2,'待收获')"><i class="el-icon-view el-icon--right"></i></span>  
                        <span >已产出:</span> <span>{{ scope.row.hold_produced_count }}</span><span  class="see_span" @click="goisharvested_but(scope.row,3,'已收获')"><i class="el-icon-view el-icon--right"></i></span>    
                    </template>
                </el-table-column>
                 <el-table-column :label="variable_name1"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.kmb }}</span>
                    </template>
                </el-table-column>
                 <el-table-column :label="variable_name2"  align='center'>                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.gdb }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="是否回本"  align='center' >                   
                    <template slot-scope="scope">                 
                        <!-- <span>{{ js_fun(scope.row.total_profit,scope.row.use_price_number) }}</span> -->
                         <span>{{ js_fun(scope.row.jindan,scope.row.caidan,scope.row.total_profit,scope.row.hold_price,scope.row.hold_wait_price,) }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="是否活跃玩家"   align='center' width="130px">                   
                    <template slot-scope="scope">                   
                        <span v-if="scope.row.activity_status == 0">不活跃</span>
                        <span v-if="scope.row.activity_status == 1">活跃</span>
                    </template>
                </el-table-column>
                <el-table-column label="状态"  align='center' width="150">                   
                    <template slot-scope="scope">                   
                        <span v-if="scope.row.total_profit >= scope.row.use_price_number">已完成</span>
                        <span v-else>未完成</span>
                    </template>
                </el-table-column>
                <el-table-column label="是否回收"  align='center'  fixed="right" width="100">                   
                    <template slot-scope="scope">                   
                        <el-switch  
                            :active-value="active" 
                            :inactive-value="isactive" 
                            v-model="scope.row.admin_handle_account" 
                            @change="switchchange(scope.row)"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"> 
                         </el-switch> 
                    </template>
                </el-table-column>
                  <el-table-column label="操作" align='center' width="200px"  fixed="right">
                    <template slot-scope="scope">
                        <el-button   size="mini"  type="primary"  plain class="button_class1" @click="go_holddetails(scope.row)">蜂巢列表</el-button> 
                    </template>
                </el-table-column>
                
 
            </el-table>  
   </div>
</template>

<script>

export default {
   name: 'searchlist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
         active:1,  //冻结登录
        isactive:0,  //冻结登录
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 303
      
  },
  mounted (){
    
  },
  methods: {
    //   js_fun(a,b){
    //         var name1 = Number(a)
    //         var name2 = Number(b)
    //         if( isNaN(name1/name2) == true){
    //             return 0
    //         }else{
    //             var number =  name1/name2
    //             return number.toFixed(2)
    //         }
             
    //   },
    js_fun(a,b,c,d,e){
            var name1 = Number(a)
            var name2 = Number(b)
            var name3 = Number(c)
            var name4 = Number(d)
            var name5 = Number(e)
            var num1 = name1 + name2 + name3
            var num2 = name4 + name5
            //console.log(num1,num2)
            if( num1 > num2){
                return '回本'
            }else{
                
                return '未回本'
            }
             
      },
      js_fun_num(a,b,c,d,e){
            var name1 = Number(a)
            var name2 = Number(b)
            var name3 = Number(c)
            var name4 = Number(d)
            var name5 = Number(e)
            var num1 = name1 + name2 + name3
            var num2 = name4 + name5
            console.log(num1,num2)
            if(num1 == num2){
                 return 0
            }else{

                if( num1 > num2){
                   var ca =  Number(num1)  - Number(num2)  
                   return  '+' + parseInt(ca) 
                }else{
                    var ca =  Number(num2)  - Number(num1) 
                    return  '-' + parseInt(ca) 
                }
                 
            }
            
      },
      switchchange(row){

          if(row.admin_handle_account != 0){
                 this.$confirm('是否冻结, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                    }).then(() => {
                            this.post("/Statistics/coldMemberGoodsStatus", {
                                uid:row.uid,
                            }).then(res => {

                                if(res.error_code == 0){
                                this.open1(res.result,'success')  //提示框
                                this.$emit('up_list_fun')
                                }else {
                                this.open1(res.message,'warning')
                            }

                        })
                    }).catch(() => {
                            this.$emit('up_list_fun') 
                    });
          }else{

              this.$confirm('是否解冻, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                    }).then(() => {
                            this.post("/Statistics/relieveColdMemberGoodsStatus", {
                                uid:row.uid,
                            }).then(res => {

                                if(res.error_code == 0){
                                this.open1(res.result,'success')  //提示框
                                this.$emit('up_list_fun')
                                }else {
                                this.open1(res.message,'warning')
                            }

                        })
                    }).catch(() => {
                            this.$emit('up_list_fun') 
                    });

          }

        //   this.$confirm('是否回收, 是否继续?', '提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   type: 'warning'
        //  }).then(() => {
        //         this.post("/member/frozenLogin", {
        //             uid:row.uid,
        //         }).then(res => {

        //             if(res.error_code == 0){
        //             this.open1(res.result,'success')  //提示框
        //             this.$emit('up_list_fun')
        //             }else {
        //             this.open1(res.message,'warning')
        //         }

        //      })
        // }).catch(() => {
        //           this.$emit('up_list_fun') 
        // });

    
    },
      gohold_but(row,type,typename){
       
       this.user_name = row.telphone
        this.$router.push({
          path: '/index/hold',
          query: {
            name:this.user_name,
            id:row.uid,
            type:type,
            typename:typename
          }
        })

    },
    goharvested_but(row,type,typename){
       
       this.user_name = row.telphone
        this.$router.push({
          path: '/index/harvested',
          query: {
            name:this.user_name,
            id:row.uid,
            type:type,
            typename:typename
          }
        })

    },
      go_holddetails(row){
            this.$router.push({
            path: '/index/holddetails',
            query: {
                name:row.telphone,
                id:row.uid,
            }
            })
      }

  }
}
</script>


<style scoped>

</style>